package com.hycat.mail.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hycat.mail.product.entity.SkuInfoEntity;
import com.hycat.mail.product.service.SkuInfoService;
import com.hycat.mail.common.utils.PageUtil;
import com.hycat.mail.common.utils.R;



/**
 * sku信息
 *
 * @author lzhycat
 * @email 2680628835@qq.com
 * @date 2022-07-16 19:53:30
 */
@RestController
@RequestMapping("/product/skuinfo")
public class SkuInfoController {
    @Autowired
    private SkuInfoService skuInfoService;

    @GetMapping("/page")
    public R page(@RequestParam Map<String, Object> params){
        PageUtil page = skuInfoService.queryPage(params);
        return R.ok().put("data", page);
    }


    @GetMapping("/info/{skuId}")
    public SkuInfoEntity skuInfo(@PathVariable("skuId") Long skuId){
		SkuInfoEntity skuInfo = skuInfoService.getById(skuId);
        return skuInfo;
    }

    @GetMapping("/listBySkuIds")
    public List<SkuInfoEntity> listBySkuIds(@RequestParam("skuIds") List<Long> skuIds) {
        return skuInfoService.listBySkuIds(skuIds);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:skuinfo:save")
    public R save(@RequestBody SkuInfoEntity skuInfo){
		skuInfoService.save(skuInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:skuinfo:update")
    public R update(@RequestBody SkuInfoEntity skuInfo){
		skuInfoService.updateById(skuInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:skuinfo:delete")
    public R delete(@RequestBody Long[] skuIds){
		skuInfoService.removeByIds(Arrays.asList(skuIds));

        return R.ok();
    }

}
